package schema

import (
	"entgo.io/ent"
	"entgo.io/ent/dialect/entsql"
	"entgo.io/ent/schema"
	"entgo.io/ent/schema/field"
	"time"
)

const (
	RoleUnEnable = 0
	RoleEnable   = 1
)

type AdminRole struct {
	ent.Schema
}

// Fields of the User.
func (AdminRole) Fields() []ent.Field {
	return []ent.Field{
		field.Int64("id"),
		field.String("role_name").MaxLen(255).Default("").Comment("角色名称"),
		field.String("role_key").MaxLen(255).Default("").Comment("角色标识"),
		field.Bool("status").Default(true).Comment("状态"),
		field.String("describe").MaxLen(255).Default("").Comment("备注"),
		field.JSON("menu_auth", []string{}).Default([]string{}).Comment("菜单权限"),
		field.JSON("btn_auth", []string{}).Default([]string{}).Comment("按钮权限"),
		field.Time("created_at").Default(time.Now).Comment("创建时间"),
		field.Time("updated_at").Default(time.Now).UpdateDefault(time.Now).Comment("更新时间"),
	}
}

// Edges of the User.
func (AdminRole) Edges() []ent.Edge {
	return nil
}

func (AdminRole) Annotations() []schema.Annotation {
	return []schema.Annotation{
		entsql.Annotation{Table: "admin_role"},
	}
}
